package com.mayikt;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: maplefire
 * @Description: NewCachedThreadPoolTest
 * @Date: 2022/09/02 15:33
 */

public class NewCachedThreadPoolTest {
    public static void main(String[] args) {
        // 可缓存的线程池  重复利用  无限大小
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 10; i++) {
            final int temp = i;
            executorService.execute(new Runnable() {
                public void run() {
                    System.out.println(Thread.currentThread().getName() + "," + temp);
                }
            });
        }
    }
}
